package com.bml.architect.rabbitmq.pubsub;

import com.bml.architect.rabbitmq.utils.RabbitConstant;
import com.bml.architect.rabbitmq.utils.RabbitUtils;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

/**
 * 发布订阅模式
 */

public class Publishor {

    public static void main(String[] args) throws Exception {
        Connection connection = RabbitUtils.getConnection();

        Channel channel = connection.createChannel();
        for (int i = 0; i < 10; i++) {
            channel.basicPublish(RabbitConstant.exchange_attention,"",null,("我发表了一篇文章" + i).getBytes());
        }
        channel.close();
        connection.close();
    }
}
